package com.example.rvdemo.slide;

import android.app.Activity;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.widget.Button;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.rvdemo.R;

import java.util.ArrayList;
import java.util.List;

public class SlideActivity extends Activity {
    private SlideRecyclerView sliderv;
    private List<String> datas;
    private RVSimpleAdaptar2 rvSimpleAdaptar2;
    private Button btn_del;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rv_slide);
        sliderv = findViewById(R.id.sliderv);
        btn_del = findViewById(R.id.btn_del);
        datas = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            datas.add("hello "+i);
        }
        rvSimpleAdaptar2 = new RVSimpleAdaptar2(this,datas);
        rvSimpleAdaptar2.setOnDelClickListener(new RVSimpleAdaptar2.OnDelClickListener() {
            @Override
            public void delItem(int pos) {
                rvSimpleAdaptar2.getDatas().remove(pos);
                rvSimpleAdaptar2.notifyDataSetChanged();
            }
        });

        Animation loadAnim = AnimationUtils.loadAnimation(this,R.anim.item_anim_translate);
        LayoutAnimationController layoutAnimationController = new LayoutAnimationController(loadAnim);
        layoutAnimationController.setOrder(LayoutAnimationController.ORDER_NORMAL);
        sliderv.setLayoutAnimation(layoutAnimationController);

        sliderv.setAdapter(rvSimpleAdaptar2);
        sliderv.setLayoutManager(new LinearLayoutManager(this));

    }
}
